package com.datastructure.test.recall.childrenofarray;

import java.util.*;

public class ChildrenOfArray {
    public static void main(String[] args) {
        int max = 0;
        int a = 0;
        int b = 0;
        int c = 0;
        Scanner scanner = new Scanner(System.in);
        String data = scanner.nextLine();
        int length = data.length();
        if(length<6){
            System.out.println(0);
        }
        String[] split = data.split("");
        for (String s : split) {
            if(s.equals("a")){
                a++;
            } else if(s.equals("b")) {
                b++;
            }else if(s.equals("c")) {
                c++;
            }
        }
        a = a/2;
        c = c/3;

        max = Math.min(a,c);
        max = Math.min(max,b);
        System.out.println(max);
    }

    public static ArrayList<String> Permutation(String str) {
        ArrayList<String> result = new ArrayList<>();
        if(str.length() == 0){
            return result;
        }

        recur(str,"",result);
        return result;
    }

    public static void recur(String str,String cur,ArrayList<String> result){
        if(str.length() == 0){
            if(!result.contains(cur)){
                result.add(cur);
            }
        }
        for(int i = 0; i < str.length();i++){
            recur(str.substring(0,i)+str.substring(i+1,str.length()),cur+str.charAt(i),result);
        }
    }
}
